home *** CD-ROM | disk | FTP | other *** search
/ Inter.Net 55-1 / Inter.Net 55-1.iso / CBuilder / Setup / BCB / data.z / dialogs.int < prev    next >
Encoding:
Text File  |  1998-02-09  |  8.1 KB  |  251 lines

  1.  
  2. {*******************************************************}
  3. {                                                       }
  4. {       Delphi Visual Component Library                 }
  5. {                                                       }
  6. {       Copyright (c) 1995,98 Borland International     }
  7. {                                                       }
  8. {*******************************************************}
  9.  
  10. unit Dialogs;
  11.  
  12. {$R-}
  13.  
  14. interface
  15.  
  16. uses Windows, Messages, SysUtils, CommDlg, Classes, Graphics, Controls,
  17.   Forms, StdCtrls;
  18.  
  19. const
  20.  
  21. { Maximum number of custom colors in color dialog }
  22.  
  23.   MaxCustomColors = 16;
  24.  
  25. type
  26.  
  27. { TCommonDialog }
  28.  
  29.   TCommonDialog = class(TComponent)
  30.   protected
  31.     procedure DefaultHandler(var Message); override;
  32.     procedure DoClose; dynamic;
  33.     procedure DoShow; dynamic;
  34.     procedure WndProc(var Message: TMessage); virtual;
  35.     function MessageHook(var Msg: TMessage): Boolean; virtual;
  36.     function TaskModalDialog(DialogFunc: Pointer; var DialogData): Bool; virtual;
  37.     function Execute: Boolean; virtual; abstract;
  38.     property Template: PChar;
  39.   public
  40.     constructor Create(AOwner: TComponent); override;
  41.     destructor Destroy; override;
  42.     property Handle: HWnd;
  43.   published
  44.     property Ctl3D: Boolean default True;
  45.     property HelpContext: THelpContext default 0;
  46.     property OnClose: TNotifyEvent;
  47.     property OnShow: TNotifyEvent;
  48.   end;
  49.  
  50. { TOpenDialog }
  51.  
  52.   TOpenOption = (ofReadOnly, ofOverwritePrompt, ofHideReadOnly,
  53.     ofNoChangeDir, ofShowHelp, ofNoValidate, ofAllowMultiSelect,
  54.     ofExtensionDifferent, ofPathMustExist, ofFileMustExist, ofCreatePrompt,
  55.     ofShareAware, ofNoReadOnlyReturn, ofNoTestFileCreate, ofNoNetworkButton,
  56.     ofNoLongNames, ofOldStyleDialog, ofNoDereferenceLinks);
  57.   TOpenOptions = set of TOpenOption;
  58.  
  59.   TFileEditStyle = (fsEdit, fsComboBox);
  60.  
  61.   TOpenDialog = class(TCommonDialog)
  62.   protected
  63.     function CanClose(var OpenFileName: TOpenFileName): Boolean;
  64.     function DoCanClose: Boolean; dynamic;
  65.     function DoExecute(Func: Pointer): Bool;
  66.     procedure DoSelectionChange; dynamic;
  67.     procedure DoFolderChange; dynamic;
  68.     procedure DoTypeChange; dynamic;
  69.     procedure DefineProperties(Filer: TFiler); override;
  70.     procedure GetFileNames(var OpenFileName: TOpenFileName);
  71.     function GetStaticRect: TRect; virtual;
  72.     procedure WndProc(var Message: TMessage); override;
  73.   public
  74.     constructor Create(AOwner: TComponent); override;
  75.     destructor Destroy; override;
  76.     function Execute: Boolean; override;
  77.     property FileEditStyle: TFileEditStyle;
  78.     property Files: TStrings;
  79.     property HistoryList: TStrings;
  80.   published
  81.     property DefaultExt: string;
  82.     property FileName: TFileName;
  83.     property Filter: string;
  84.     property FilterIndex: Integer default 1;
  85.     property InitialDir: string;
  86.     property Options: TOpenOptions default [ofHideReadOnly];
  87.     property Title: string;
  88.     property OnCanClose: TCloseQueryEvent;
  89.     property OnFolderChange: TNotifyEvent;
  90.     property OnSelectionChange: TNotifyEvent;
  91.     property OnTypeChange: TNotifyEvent;
  92.   end;
  93.  
  94. { TSaveDialog }
  95.  
  96.   TSaveDialog = class(TOpenDialog)
  97.     function Execute: Boolean; override;
  98.   end;
  99.  
  100. { TColorDialog }
  101.  
  102.   TColorDialogOption = (cdFullOpen, cdPreventFullOpen, cdShowHelp,
  103.     cdSolidColor, cdAnyColor);
  104.   TColorDialogOptions = set of TColorDialogOption;
  105.  
  106.   TCustomColors = array[0..MaxCustomColors - 1] of Longint;
  107.  
  108.   TColorDialog = class(TCommonDialog)
  109.   public
  110.     constructor Create(AOwner: TComponent); override;
  111.     destructor Destroy; override;
  112.     function Execute: Boolean; override;
  113.   published
  114.     property Color: TColor default clBlack;
  115.     property Ctl3D default False;
  116.     property CustomColors: TStrings;
  117.     property Options: TColorDialogOptions default [];
  118.   end;
  119.  
  120. { TFontDialog }
  121.  
  122.   TFontDialogOption = (fdAnsiOnly, fdTrueTypeOnly, fdEffects,
  123.     fdFixedPitchOnly, fdForceFontExist, fdNoFaceSel, fdNoOEMFonts,
  124.     fdNoSimulations, fdNoSizeSel, fdNoStyleSel,  fdNoVectorFonts,
  125.     fdShowHelp, fdWysiwyg, fdLimitSize, fdScalableOnly, fdApplyButton);
  126.   TFontDialogOptions = set of TFontDialogOption;
  127.  
  128.   TFontDialogDevice = (fdScreen, fdPrinter, fdBoth);
  129.  
  130.   TFDApplyEvent = procedure(Sender: TObject; Wnd: HWND) of object;
  131.  
  132.   TFontDialog = class(TCommonDialog)
  133.   protected
  134.     procedure Apply(Wnd: HWND); dynamic;
  135.     procedure WndProc(var Message: TMessage); override;
  136.   public
  137.     constructor Create(AOwner: TComponent); override;
  138.     destructor Destroy; override;
  139.     function Execute: Boolean; override;
  140.   published
  141.     property Font: TFont;
  142.     property Device: TFontDialogDevice default fdScreen;
  143.     property MinFontSize: Integer;
  144.     property MaxFontSize: Integer;
  145.     property Options: TFontDialogOptions default [fdEffects];
  146.     property OnApply: TFDApplyEvent;
  147.   end;
  148.  
  149. { TPrinterSetupDialog }
  150.  
  151.   TPrinterSetupDialog = class(TCommonDialog)
  152.   public
  153.     function Execute: Boolean; override;
  154.   end;
  155.  
  156. { TPrintDialog }
  157.  
  158.   TPrintRange = (prAllPages, prSelection, prPageNums);
  159.   TPrintDialogOption = (poPrintToFile, poPageNums, poSelection, poWarning,
  160.     poHelp, poDisablePrintToFile);
  161.   TPrintDialogOptions = set of TPrintDialogOption;
  162.  
  163.   TPrintDialog = class(TCommonDialog)
  164.   public
  165.     function Execute: Boolean; override;
  166.   published
  167.     property Collate: Boolean default False;
  168.     property Copies: Integer default 0;
  169.     property FromPage: Integer default 0;
  170.     property MinPage: Integer default 0;
  171.     property MaxPage: Integer default 0;
  172.     property Options: TPrintDialogOptions default [];
  173.     property PrintToFile: Boolean default False;
  174.     property PrintRange: TPrintRange default prAllPages;
  175.     property ToPage: Integer default 0;
  176.   end;
  177.  
  178. { TFindDialog }
  179.  
  180.   TFindOption = (frDown, frFindNext, frHideMatchCase, frHideWholeWord,
  181.     frHideUpDown, frMatchCase, frDisableMatchCase, frDisableUpDown,
  182.     frDisableWholeWord, frReplace, frReplaceAll, frWholeWord, frShowHelp);
  183.   TFindOptions = set of TFindOption;
  184.  
  185.   TFindReplaceFunc = function(var FindReplace: TFindReplace): HWnd stdcall;
  186.  
  187.   TFindDialog = class(TCommonDialog)
  188.   protected
  189.     function MessageHook(var Msg: TMessage): Boolean; override;
  190.     procedure Find; dynamic;
  191.     procedure Replace; dynamic;
  192.   public
  193.     constructor Create(AOwner: TComponent); override;
  194.     destructor Destroy; override;
  195.     procedure CloseDialog;
  196.     function Execute: Boolean; override;
  197.     property Left: Integer;
  198.     property Position: TPoint;
  199.     property Top: Integer;
  200.   published
  201.     property FindText: string;
  202.     property Options: TFindOptions default [frDown];
  203.     property OnFind: TNotifyEvent;
  204.   end;
  205.  
  206. { TReplaceDialog }
  207.  
  208.   TReplaceDialog = class(TFindDialog)
  209.   public
  210.     constructor Create(AOwner: TComponent); override;
  211.   published
  212.     property ReplaceText;
  213.     property OnReplace;
  214.   end;
  215.  
  216. { Message dialog }
  217.  
  218. type
  219.   TMsgDlgType = (mtWarning, mtError, mtInformation, mtConfirmation, mtCustom);
  220.   TMsgDlgBtn = (mbYes, mbNo, mbOK, mbCancel, mbAbort, mbRetry, mbIgnore,
  221.     mbAll, mbNoToAll, mbYesToAll, mbHelp);
  222.   TMsgDlgButtons = set of TMsgDlgBtn;
  223.  
  224. const
  225.   mbYesNoCancel = [mbYes, mbNo, mbCancel];
  226.   mbOKCancel = [mbOK, mbCancel];
  227.   mbAbortRetryIgnore = [mbAbort, mbRetry, mbIgnore];
  228.  
  229. function CreateMessageDialog(const Msg: string; DlgType: TMsgDlgType;
  230.   Buttons: TMsgDlgButtons): TForm;
  231.  
  232. function MessageDlg(const Msg: string; DlgType: TMsgDlgType;
  233.   Buttons: TMsgDlgButtons; HelpCtx: Longint): Integer;
  234. function MessageDlgPos(const Msg: string; DlgType: TMsgDlgType;
  235.   Buttons: TMsgDlgButtons; HelpCtx: Longint; X, Y: Integer): Integer;
  236. function MessageDlgPosHelp(const Msg: string; DlgType: TMsgDlgType;
  237.   Buttons: TMsgDlgButtons; HelpCtx: Longint; X, Y: Integer;
  238.   const HelpFileName: string): Integer;
  239.  
  240. procedure ShowMessage(const Msg: string);
  241. procedure ShowMessageFmt(const Msg: string; Params: array of const);
  242. procedure ShowMessagePos(const Msg: string; X, Y: Integer);
  243.  
  244. { Input dialog }
  245.  
  246. function InputBox(const ACaption, APrompt, ADefault: string): string;
  247. function InputQuery(const ACaption, APrompt: string;
  248.   var Value: string): Boolean;
  249.  
  250. implementation
  251.